﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Program19
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 画直线
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLine_Click(object sender, EventArgs e)
        {
            //创建GDI对象
            Graphics g = this.CreateGraphics();

            //创建画笔对象
            Pen pen = new Pen(Brushes.Gray,10);
            //线条风格
            //pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            float[] dash = { 2, 15, 8,2 };
            pen.DashPattern = dash;

            //画直线，建立坐标
            Point p1 = new Point(40, 60);
            Point p2 = new Point(800, 60);

            //绘制直线
            g.DrawLine(pen, p1, p2);
        }

        private void btnRact_Click(object sender, EventArgs e)
        {
            //创建GDI对象
            Graphics g = this.CreateGraphics();

            //创建画笔对象
            Pen pen = new Pen(Brushes.Gray, 10);

            //定义矩形大小
            Size size = new Size(100, 100);
            //定义开始坐标
            Point startPoint = new Point(50, 100);
            //定义矩形
            Rectangle rectangle = new Rectangle(startPoint, size);
            g.DrawRectangle(pen, rectangle);
            g.DrawEllipse(pen, rectangle);
        }

        private void btnCircular_Click(object sender, EventArgs e)
        {
            //创建GDI对象
            Graphics g = this.CreateGraphics();

            //创建画笔对象
            Pen pen = new Pen(Brushes.LightGray, 10);
            g.DrawEllipse(pen, 100, 100, 100, 100);
        }

        private void btnPic_Click(object sender, EventArgs e)
        {
            //创建GDI对象
            Graphics g = this.CreateGraphics();

            //创建画笔对象
            Pen pen = new Pen(Brushes.LightGray, 10);
            g.DrawPie(pen, 100, 100, 200, 200, 45, 90);
            SolidBrush brush = new SolidBrush(Color.LightGoldenrodYellow);
            g.FillPie(brush, 100, 100, 200, 200, 225, 90);

            //写字
            g.DrawString("阿西吧", new Font("微软雅黑", 20, FontStyle.Regular), Brushes.Black, new Point(50, 150));
        }
    }
}
